package com.systemsjr.mpf.expense;

import java.io.Serializable;

import android.net.Uri;

import com.systemsjr.mpf.db.ExpenseTypeContentProvider;

public class ExpenseType implements Serializable, Cloneable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6768221060715289685L;

	// THE CONTENT URI TO OUR PROVIDER
	public static final Uri CONTENT_URI = Uri.parse("content://"
			+ ExpenseTypeContentProvider.AUTHORITY + "/expenseType");

	// MIME TYPE FOR GROUP OF ACCOUNTS
	public static final String CONTENT_TYPE = "vnd.android.cursor.dir/com.systemsjr.mpf.expenseType";

	// MIME TYPE FOR SINGLE ACCOUNT
	public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/com.systemsjr.mpf.expenseType";

	// RELATIVE POSITION OF CITIZEN SSID IN URI
	public static final int CODE_PATH_POSITION = 1;

	public static final String TABLE_NAME = "EXPENSE_TYPE";
	public static final String ID = "_id";
	public static final String CODE = "CODE";
	public static final String EXPENSE_TYPE = "EXPENSE_TYPE";	
	public static final String SPENT = "SPENT";

	public static String[] PROJECTIONS = { ExpenseType.ID,
		ExpenseType.CODE, ExpenseType.EXPENSE_TYPE};

	private Long id;
	private String code, expenseType;
	private double spent;

	public ExpenseType() {
		id = 0L;
		spent = 0.00;
	}

	public ExpenseType(Long id, String code, String expenseType, double spent) {
		this.id = id;
		this.code = code;
		this.expenseType = expenseType;
		this.spent = spent;
	}
	
	public ExpenseType(String code, String expenseType) {
		this.id = 0L;
		this.code = code;
		this.expenseType = expenseType;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getExpenseType() {
		return expenseType;
	}

	public void setExpenseType(String expenseType) {
		this.expenseType = expenseType;
	}
	
	public double getSpent() {
		return spent;
	}

	public void setSpent(double spent) {
		this.spent = spent;
	}
	
	public static String[] getNewProjections(){
		return new String[]{ExpenseType.ID,
				ExpenseType.CODE, ExpenseType.EXPENSE_TYPE, ExpenseType.SPENT};
	}

	public static String createTable() {

		return "CREATE TABLE " + TABLE_NAME + "(" + ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," + CODE
				+ " TEXT not null unique," + EXPENSE_TYPE
				+ " TEXT BINARY not null unique)";
	}
	
	public ExpenseType clone(){
		
		ExpenseType et = new ExpenseType(code, expenseType);
		et.setId(id);
		et.setSpent(spent);
		
		return et;
	}

}
